package com.fjnu.controller.storage;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fjnu.controller.common.BaseController;
import com.fjnu.service.InstrumentService;

/**
 * 实现资产的批量操作
 * 退库
 * 报废
 * @author 默默
 *
 */
@Controller
public class ManyOutStorageController extends BaseController{
	@Autowired
	private InstrumentService instrumentService;
	/**
	 * 资产进行批量退库
	 * @param outId
	 * @return
	 */
	@RequestMapping(value="/delManyIns")
	@ResponseBody
	public Map<String,Object> manyOutStorage(String outId){
		if(!init(outId).get(STATUS).equals(SUCCESS))
			return getData2Result();
		 String[] arr = new String[outId.length()];
		List<Integer> listId= new ArrayList<Integer>();
		for(int i=0;i<outId.length();i++){
			arr[i]=outId.substring(i, i+1);
			listId.add(Integer.parseInt(arr[i]));
		}
		instrumentService.delManyIns(listId);
		return getData2Result();
	}
	/**
	 * 资产批量报废
	 * @param deadId
	 * @return
	 */
	@RequestMapping(value="/manyTodead")
	@ResponseBody
	public Map<String,Object> manyToDead(String deadId){
		if(!init(deadId).get(STATUS).equals(SUCCESS))
			return getData2Result();
		String[] arr = new String[deadId.length()];
		List<Integer> listId= new ArrayList<Integer>();
		for(int i=0;i<deadId.length();i++){
			arr[i]=deadId.substring(i, i+1);
			listId.add(Integer.parseInt(arr[i]));
		}
		instrumentService.manyToDead(listId);
		return getData2Result();
	}
	
}
